package com.briup;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class GetStuAndClassByStep {
  public static void main(String[] args) {
    String resource = "mybatis-config.xml";
      SqlSession sqlSession = null;
      try (InputStream resourceAsStream = Resources.getResourceAsStream(resource)) {
          SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsStream);
          sqlSession = build.openSession();
          StuMapper mapper = sqlSession.getMapper(StuMapper.class);
          Student stuByStep = mapper.getStuByStep(2);
      System.out.println(stuByStep);
      }catch (Exception e){
          e.printStackTrace();
      }finally{
          sqlSession.close();
      }
  }
}
